package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.base.util.LogUtils
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.SearchArticleModel
import com.powervision.mvvmdemo.ui.repository.SearchArticleRepository

/**
 * @auth: njb
 * @date: 2021/12/20 14:35
 * @desc: 描述
 */
class SearchArticleViewModel : BaseViewModel() {
    private val mSearchArticleRepository by lazy { SearchArticleRepository() }
    val mSearchLiveData = StateLiveData<List<SearchArticleModel>>()

    fun searchArticle(page:Int,author: String) {
        launchWithLoading(requestBlock = {
            mSearchArticleRepository.searchArticle(page,author = author)
        }, resultCallback = {
            mSearchLiveData.value = it
            LogUtils.d("searchInfo",it.data.toString())
        })
    }
}
